#
#  Copyright 2008 Garth Williams
#
#  This file is part of CommandPost.
#
#  CommandPost is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  CommandPost is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with CommandPost.  If not, see <http://www.gnu.org/licenses/>.
#

class AddInitialData < ActiveRecord::Migration
  def self.up
    Page.transaction do
      administrator = User.find_by_name('Administrator')
      Page.new(:name => 'homepage_content', :title => 'Home Screen',
        :body => "Welcome to CommandPost.\n\nSign in and click edit to change this introduction.",
        :created_by => administrator).save!
      Page.new(:name => 'sidebar_content', :title => 'Project Pages',
        :body => 'Sign in and click edit to add your project links here.',
        :created_by => administrator).save!
    end
  end

  def self.down
    Page.transaction do
      Page.destroy_all(['name = ?', 'homepage_content'])
      Page.destroy_all(['name = ?', 'sidebar_content'])
    end
  end
end
